package com.java.yz.day11.ketang;

import java.util.ArrayList;
import java.util.Random;

//获取10个1-20之间的随机数，要求不能重复
public class ListText3 {
    public static void main(String[] args) {
        ArrayList<Integer> integers1 = new ArrayList<>(); //旧容器
        ArrayList<Integer> integers2 = new ArrayList<>(); //新容器
        Random random = new Random();
        int i = random.nextInt(20)+1;
        boolean flag = true;
        while (flag){
            integers1.add(i);
            for (int j = 0; j < integers1.size(); j++) {
                Integer integer=integers1.get(j);
                while (! integers2.contains(integers1.get(integer))){
                    integers2.add(integer);
                }
            }

            if (integers2.size()==10){
                flag=false;
                break;
            }
        }
        System.out.println(integers2);



    }
}
